2020年5月25日 | Leave a comment 问题: 在新线程中访问 entityManager 报错 2020-05-25 13:26:32,856 WARN [cra.PageService] (Thread-45) 采集出错: javax.enterprise.context.ContextNotActiveException: interface javax.enterprise.context.RequestScoped at io.quarkus.hibernate.orm.runtime.RequestScopedEntityManagerHolder_ClientProxy.arc$delegate(RequestScopedEntityManagerHolder_ClientProxy.zig:83) at io.quarkus.hibernate.orm.runtime.RequestScopedEntityManagerHolder_ClientProxy.getOrCreateEntityManager(RequestScopedEntityManagerHolder_ClientProxy.zig:191) at io.quarkus.hibernate.orm.runtime.entitymanager.TransactionScopedEntityManager.getEntityManager(TransactionScopedEntityManager.java:77) at io.quarkus.hibernate.orm.runtime.entitymanager.TransactionScopedEntityManager.createNamedQuery(TransactionScopedEntityManager.java:364) at io.quarkus.hibernate.orm.runtime.entitymanager.ForwardingEntityManager.createNamedQuery(ForwardingEntityManager.java:172) 123456 2020-05-25 13:26:32,856 WARN [cra.PageService] (Thread-45) 采集出错: javax.enterprise.context.ContextNotActiveException: interface javax.enterprise.context.RequestScoped at io.quarkus.hibernate.orm.runtime.RequestScopedEntityManagerHolder_ClientProxy.arc$delegate(RequestScopedEntityManagerHolder_ClientProxy.zig:83) at io.quarkus.hibernate.orm.runtime.RequestScopedEntityManagerHolder_ClientProxy.getOrCreateEntityManager(RequestScopedEntityManagerHolder_ClientProxy.zig:191) at io.quarkus.hibernate.orm.runtime.entitymanager.TransactionScopedEntityManager.getEntityManager(TransactionScopedEntityManager.java:77) at io.quarkus.hibernate.orm.runtime.entitymanager.TransactionScopedEntityManager.createNamedQuery(TransactionScopedEntityManager.java:364) at io.quarkus.hibernate.orm.runtime.entitymanager.ForwardingEntityManager.createNamedQuery(ForwardingEntityManager.java:172) 解决: 参考: